package com.hzmall.common;

public class Const {
    public static final String LOCAL_USER="LOCAL_USER";
    public static final String USERNAME="username";
    public static final String EMAIL="email";

    public interface ROLE{
        int ROLE_CUSTOMER=0;
        int ROLE_ADMIN=1;
    }
    public enum STATUS_CODE{
        NEED_LOGIN(10,"NEED_LOGIN");
        private int code;
        private String desc;

        public int getCode() {
            return code;
        }

        public String getDesc() {
            return desc;
        }
        STATUS_CODE(int code,String desc){
            this.code = code;
            this.desc = desc;
        }
    }
    public static final int CookieExpireTime=1800;
    public static final String FORGET_TOKEN="forget_token";
    public static final int FORGET_TOKEN_EXPIRE = 3600;

    public enum ORDER_STATUS{
        //0-已取消-10-未付款，20-已付款，40-已发货，50-交易成功，60-交易关闭
        CANCEL(0,"已取消"),
        NO_PAY(10,"未付款"),
        PAID(20,"已付款"),
        SENDED(40,"已发货"),
        SUCCESS(50,"交易成功"),
        CLOSE(60,"交易关闭");
        private int code;
        private String desc;
        ORDER_STATUS(int code,String desc){
            this.code = code;
            this.desc = desc;
        }

        public int getCode() {
            return code;
        }

        public String getDesc() {
            return desc;
        }
        public static ORDER_STATUS codeOf(int code){
            for(ORDER_STATUS order_status : values()){
                if(order_status.getCode() == code){
                    return order_status;
                }
            }
            throw new RuntimeException("没有找到对应的枚举");
        }
    }

    public enum PAY_INFO{
        ONLINE_PAY(1,"在线支付");
        private int code;
        private String desc;
        PAY_INFO(int code,String desc){
            this.code = code;
            this.desc = desc;
        }

        public int getCode() {
            return code;
        }

        public String getDesc() {
            return desc;
        }
        public static PAY_INFO codeOf(int code){
            for (PAY_INFO pay_info : values()){
                if (pay_info.getCode() == code){
                    return pay_info;
                }
            }
            throw new RuntimeException("没有找到对应枚举类型");
        }
    }
    public interface ALIPAY_ORDER_STATUS{
        String TRADE_SUCCESS = "TRADE_SUCCESS";
        String WAIT_BUYER_PAY = "WAIT_BUYER_PAY";
        String TRADE_CLOSED = "TRADE_CLOSED";
        String TRADE_FINISHED = "TRADE_FINISHED";
    }
    public enum PAY_PLATFORM{
        ALIPAY(1,"支付宝"),
        WECHAT(2,"微信支付");
        private int code;
        private String desc;
        PAY_PLATFORM(int code,String desc){
            this.code = code;
            this.desc = desc;
        }

        public int getCode() {
            return code;
        }

        public String getDesc() {
            return desc;
        }
    }
    public interface REDIS_LOCK{
        String ORDER_TASK_LOCK = "ORDER_TASK_LOCK";
    }
}
